package top.go2do.common.module;

import lombok.Data;

import javax.persistence.*;
import java.time.LocalDateTime;

/**
 * @author xingyuji
 * @date 2025/3/16 17:54
 * @description 用户主表
 */
@Entity
@Table(name = "tag", uniqueConstraints = {
        @UniqueConstraint(name = "idx_unique_tag_name", columnNames ={"app_id", "entity_code", "tag_name", "created_by"})
})
@Data
public class TagPO {
    @Id
    @Column(name = "tag_id", columnDefinition = "BIGINT UNSIGNED COMMENT '全局唯一标签ID'")
    private Long tagId;

    @Column(name = "app_id", nullable = false, columnDefinition = "VARCHAR(32) COMMENT '所属应用ID'")
    private String appId;

    @Column(name = "entity_code", nullable = false, columnDefinition = "VARCHAR(50) COMMENT '所属实体CODE'")
    private String entityCode;

    @Column(name = "tag_name", nullable = false, columnDefinition = "VARCHAR(50) COMMENT '标签名'")
    private String tagName;

    @Column(name = "description", columnDefinition = "VARCHAR(255) COMMENT '标签描述'")
    private String description;

    @Column(name = "version", nullable = false, columnDefinition = "VARCHAR(64) COMMENT '版本号(由SHA-1 哈希算法生成)'")
    private String version;

    @Column(name = "sort", columnDefinition = "INT COMMENT '排序权重'")
    private Integer sort;

    @Column(name = "status", nullable = false, columnDefinition = "TINYINT UNSIGNED DEFAULT 1 COMMENT '1正常,2冻结'")
    private Integer status;

    @Column(name = "created_by", nullable = false, columnDefinition = "BIGINT UNSIGNED COMMENT '创建者ID'")
    private Long createdBy;

    @Column(name = "updated_by", nullable = false, columnDefinition = "BIGINT UNSIGNED COMMENT '更新者ID'")
    private Long updatedBy;

    @Column(name = "created_at", nullable = false, insertable = false, updatable = false,
            columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6) COMMENT '创建时间'")
    private LocalDateTime createdAt;

    @Column(name = "updated_at", nullable = false, insertable = false, updatable = false,
            columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6) COMMENT '更新时间'")
    private LocalDateTime updatedAt;

}
